﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.FAQ.Components;
using ASPNETVN.PORTAL.Components.Share.Controls;
using ASPNETVN.PORTAL.Components.Share;

namespace ASPNETVN.PORTAL.Modules.FAQ.Controls
{
    public partial class Detail : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {                
                Components.Item item = Components.Item.Load(this.ItemID);
                if (item != null)
                {                    
                    int categoryID = item.CategoryID;
                    Category category = Category.Load(categoryID);
                    if (category != null)
                    {
                        lblLinhVuc.Text = category.Title;
                    }

                    lblTieuDe.Text = item.Title;
                    lblNguoiGui.Text = item.Name;
                    lblEmail.Text = item.Email;
                    lblNgayGui.Text = item.QuesDate.ToString().Substring(0,item.QuesDate.ToString().IndexOf(" "));
                    lblNoiDungHoi.Text = item.QuesContent;
                    lblNguoiTraLoi.Text = item.AnwserBy;
                    lblNgayTraLoi.Text = item.AnwserDate.ToString().Substring(0, item.AnwserDate.ToString().IndexOf(" "));
                    lblNoiDungTraLoi.Text = item.AnwserContent;
                    
                }
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            string url = HttpUrlBuilder.BuildModulePageUrl(this.ModuleID, 0, ModulePages.Item);
            Response.Redirect(url);
        }
    }
}